package stud.mpgame.flash.game;

import stud.mpgame.flash.game.Player;

/**
 * ...
 * @author Artem Kirienko
 */
class GameUtils {

    private function new() {
        
    }
    
    public static function getPlayerByID(players:Array< Player >, id:Int):Player {
        for (player in players) {
            if (player.getID() == id)
                return player;
        }
        return null;
    }
    
    public static function copyPlayers(players:Array< Player >):Array< Player > {
        var playersCopy:Array< Player > = new Array< Player >();
        for (player in players) {
            playersCopy.push(player);
        }
        return playersCopy;
    }
	
	public static function interpolateDiscreteValue(oldValue:Float, deltaTime:Int, needValue:Float, interpolationDeltaTime:Int):Float {
		var differenceValue:Float = needValue - oldValue;
		var addition:Float = deltaTime * differenceValue / interpolationDeltaTime;
		return oldValue + addition;		
	}
	
}